//引入vue-router路由插件
import VueRouter from "vue-router";
//引入Vue
import Vue from "vue";

//使用插件
Vue.use(VueRouter);

import Home from "@/pages/Home";
import Login from "@/pages/Login";
import Register from "@/pages/Register";
import Search from "@/pages/Search";



//对外暴露VueRouter类的实例
const router = new VueRouter({
    //配置路由
    //第一:路径的前面需要有/(不是二级路由)
    //路径中单词都是小写的
    //component右侧V别给我加单引号【字符串：组件是对象（VueComponent类的实例）】
    routes:[
        {
            path:'/',
            redirect:'/home'
        },
        {
            path:'/home',
            component:Home,
            meta:{show:true}
        },
        {
            path:'/login',
            component:Login,
            meta:{show:false}

        },
        {
            path:'/register',
            component:Register,
            meta:{show:true}
        },  {
            name:'search',
            path:'/search/:key?',
            component:Search,
            meta:{show:false},
            // porps:true
            // porps:{a:1}
           porps:()=>{

           }


        }
    ],
    //滚动行为
    scrollBehavior(to, from, savedPosition) {
      //返回的这个y=0，代表的滚动条在最上方
      return { y: 0 };
    },
  });

export default router;